package com.javabasic.algorithm.leetcode;

public class FirstBadVersion {

    /**
     * 二分法求下界
     * @param n
     * @return
     */
    public int firstBadVersion(int n) {
        int left = 1, right = n, mid;
        while (left < right) {
            mid = left + ((right-left)>>1);
            if (isBadVersion(mid)) { // 等价于traget <= arr[mid]
                right = mid;
            } else {
                left = mid+1;
            }
        }
        return left;
    }
    boolean isBadVersion(int version) { return true; }
}
